package presentacion;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JLabel;

import java.awt.Font;

import javax.swing.SwingConstants;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.ImageIcon;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JList;
import javax.swing.JSeparator;
import javax.swing.JToolBar;
import javax.swing.ListSelectionModel;
import javax.swing.UnsupportedLookAndFeelException;

import dominio.Competicion;
import dominio.ListenerCerrarVentana;
import dominio.OtroListCellRenderer;
import dominio.Util;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import javax.swing.border.EtchedBorder;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.ListSelectionEvent;

import java.awt.Cursor;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JRadioButtonMenuItem;
import javax.swing.ButtonGroup;
import javax.swing.UIManager;
import java.awt.Color;
import javax.swing.border.SoftBevelBorder;
import javax.swing.border.BevelBorder;
import javax.swing.border.MatteBorder;

public class CompeticionX {

	JFrame VentanaCompeticionX;
	private JLabel lblCompeticionx;
	private JLabel lblDia;
	private JLabel lblHora;
	private JLabel lblPrecio;
	private JLabel lblPremios;
	private JPanel pnlRecorrido;
	private JLabel lblDia_;
	private JLabel lblHora_;
	private JLabel lblPrecio_;
	private JLabel lblPremio_;
	private JButton btnBorrar;
	JButton btnEstadisticas;
	private JButton btnEditar;
	private JButton btnAtras;
	private JLabel lblSalida;
	private JLabel lblMeta;
	private JLabel lblDificultad;
	private JLabel lblDistancia;
	private JLabel lblSalidaM;
	private JLabel lblMetaM;
	private JLabel lblDistanciaM;
	private JLabel lblDificultadM;
	private JScrollPane sPParticipantes;
	private JList listParticipantes;
	private JToolBar toolBar;
	JButton btnAadirParticipante;
	private JButton btnNotificar;
	private JButton btnAyuda;
	private JMenuBar menuBar;
	private JMenu mnArchivo;
	private JMenu mnGestion;
	private JMenu mnAyuda;
	private JMenuItem mntmAcercaDe;
	private JMenuItem mntmAyuda;
	private JMenuItem mnNotificacion;
	private JMenuItem mnAniadirParticipante;
	private JMenuItem mntmBorrar;
	private JMenuItem mntmEditar;
	private JMenuItem mntmEstadisticas;
	private JMenuItem mntmAtras;
	private JMenuItem mntmSalir;
	private JSeparator separator;
	private JMenu mnCambiarIdioma;
	private JRadioButtonMenuItem mntmEspaol;
	private JRadioButtonMenuItem mntmIngls;
	private JSeparator separator_1;
	private JLabel lblImagen;
	private JSeparator separator_3;
	private final ButtonGroup buttonGroup = new ButtonGroup();
	private JFrame ventanaInvocadora;
	private Competicion com;
	private JLabel label;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					CompeticionX window = new CompeticionX(null);
					window.VentanaCompeticionX.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public CompeticionX(JFrame ventana) {
		ventanaInvocadora = ventana;
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		VentanaCompeticionX = new JFrame();
		VentanaCompeticionX.addWindowListener(new ListenerCerrarVentana(
				VentanaCompeticionX));
		VentanaCompeticionX.setIconImage(Toolkit.getDefaultToolkit().getImage(
				CompeticionX.class.getResource("/recursos/LOGO.png"))); //$NON-NLS-1$
		VentanaCompeticionX.setTitle("CompeticionX"); //$NON-NLS-1$
		VentanaCompeticionX.setResizable(false);
		VentanaCompeticionX.setBounds(100, 100, 987, 614);
		VentanaCompeticionX.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		VentanaCompeticionX.getContentPane().setLayout(null);
		VentanaCompeticionX.setLocationRelativeTo(null);
		{
			lblCompeticionx = new JLabel("CompeticionX"); //$NON-NLS-1$
			lblCompeticionx.setHorizontalAlignment(SwingConstants.CENTER);
			lblCompeticionx.setFont(new Font("Nueva Std", Font.PLAIN, 25)); //$NON-NLS-1$
			lblCompeticionx.setBounds(176, 13, 662, 26);
			VentanaCompeticionX.getContentPane().add(lblCompeticionx);
		}
		{
			lblDia = new JLabel(Messages.getString("CompeticionX.4")); //$NON-NLS-1$
			lblDia.setBounds(35, 77, 50, 16);
			VentanaCompeticionX.getContentPane().add(lblDia);
		}
		{
			lblHora = new JLabel(Messages.getString("CompeticionX.5")); //$NON-NLS-1$
			lblHora.setBounds(35, 100, 50, 16);
			VentanaCompeticionX.getContentPane().add(lblHora);
		}
		{
			lblPrecio = new JLabel(Messages.getString("CompeticionX.6")); //$NON-NLS-1$
			lblPrecio.setBounds(35, 129, 140, 16);
			VentanaCompeticionX.getContentPane().add(lblPrecio);
		}
		{
			lblPremios = new JLabel(Messages.getString("CompeticionX.7")); //$NON-NLS-1$
			lblPremios.setBounds(35, 158, 72, 16);
			VentanaCompeticionX.getContentPane().add(lblPremios);
		}
		{
			pnlRecorrido = new JPanel();
			pnlRecorrido.setBorder(new TitledBorder(null, Messages
					.getString("CompeticionX.8"), //$NON-NLS-1$
					TitledBorder.LEADING, TitledBorder.TOP, null, null));
			pnlRecorrido.setBounds(35, 187, 486, 268);
			VentanaCompeticionX.getContentPane().add(pnlRecorrido);
			pnlRecorrido.setLayout(null);
			{
				lblSalida = new JLabel(Messages.getString("CompeticionX.9")); //$NON-NLS-1$
				lblSalida.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, //$NON-NLS-1$
						13));
				lblSalida.setBounds(304, 28, 147, 16);
				pnlRecorrido.add(lblSalida);
			}
			{
				lblMeta = new JLabel(Messages.getString("CompeticionX.11")); //$NON-NLS-1$
				lblMeta.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 13)); //$NON-NLS-1$
				lblMeta.setBounds(304, 85, 147, 16);
				pnlRecorrido.add(lblMeta);
			}
			{
				lblDificultad = new JLabel(
						Messages.getString("CompeticionX.13")); //$NON-NLS-1$
				lblDificultad.setFont(new Font("Tahoma", Font.BOLD //$NON-NLS-1$
						| Font.ITALIC, 13));
				lblDificultad.setBounds(304, 201, 147, 16);
				pnlRecorrido.add(lblDificultad);
			}
			{
				lblDistancia = new JLabel(Messages.getString("CompeticionX.15")); //$NON-NLS-1$
				lblDistancia.setFont(new Font("Tahoma", //$NON-NLS-1$
						Font.BOLD | Font.ITALIC, 13));
				lblDistancia.setBounds(304, 144, 147, 16);
				pnlRecorrido.add(lblDistancia);
			}
			{
				lblSalidaM = new JLabel(""); //$NON-NLS-1$
				lblSalidaM.setBounds(304, 57, 147, 16);
				pnlRecorrido.add(lblSalidaM);
			}
			{
				lblMetaM = new JLabel(""); //$NON-NLS-1$
				lblMetaM.setBounds(304, 115, 147, 16);
				pnlRecorrido.add(lblMetaM);
			}
			{
				lblDistanciaM = new JLabel(""); //$NON-NLS-1$
				lblDistanciaM.setBounds(304, 173, 147, 16);
				pnlRecorrido.add(lblDistanciaM);
			}
			{
				lblDificultadM = new JLabel(""); //$NON-NLS-1$
				lblDificultadM.setBounds(304, 230, 147, 16);
				pnlRecorrido.add(lblDificultadM);
			}
			{
				label = new JLabel(""); //$NON-NLS-1$
				label.setBorder(new MatteBorder(2, 2, 2, 2, (Color) new Color(0, 0, 0)));
				label.setIcon(new ImageIcon(CompeticionX.class.getResource("/recursos/MapaEjemplo.png")));
				label.setBounds(10, 20, 285, 228);
				pnlRecorrido.add(label);
			}
		}
		{
			lblDia_ = new JLabel(""); //$NON-NLS-1$
			lblDia_.setBounds(80, 77, 333, 16);
			VentanaCompeticionX.getContentPane().add(lblDia_);
		}
		{
			lblHora_ = new JLabel(""); //$NON-NLS-1$
			lblHora_.setBounds(80, 106, 323, 16);
			VentanaCompeticionX.getContentPane().add(lblHora_);
		}
		{
			lblPrecio_ = new JLabel(""); //$NON-NLS-1$
			lblPrecio_.setBounds(176, 129, 225, 16);
			VentanaCompeticionX.getContentPane().add(lblPrecio_);
		}
		{
			lblPremio_ = new JLabel(""); //$NON-NLS-1$
			lblPremio_.setBounds(100, 158, 303, 16);
			VentanaCompeticionX.getContentPane().add(lblPremio_);
		}
		{
			btnBorrar = new JButton(Messages.getString("CompeticionX.25")); //$NON-NLS-1$
			btnBorrar.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
			btnBorrar.addActionListener(new BorrarActionListener(
					ventanaInvocadora));
			btnBorrar.setToolTipText(Messages.getString("CompeticionX.26")); //$NON-NLS-1$
			btnBorrar.setFont(new Font("Tahoma", Font.PLAIN, 16)); //$NON-NLS-1$
			btnBorrar.setHorizontalTextPosition(SwingConstants.CENTER);
			btnBorrar.setIcon(new ImageIcon(CompeticionX.class
					.getResource("/recursos/eliminar.png"))); //$NON-NLS-1$
			btnBorrar.setVerticalTextPosition(SwingConstants.BOTTOM);
			btnBorrar.setBounds(45, 464, 97, 61);
			VentanaCompeticionX.getContentPane().add(btnBorrar);
		}
		{
			btnEstadisticas = new JButton(Messages.getString("CompeticionX.29")); //$NON-NLS-1$
			btnEstadisticas.addActionListener(new estadisticasActionListener());
			btnEstadisticas.setCursor(Cursor
					.getPredefinedCursor(Cursor.HAND_CURSOR));
			btnEstadisticas
					.setToolTipText(Messages.getString("CompeticionX.0")); //$NON-NLS-1$
			btnEstadisticas.setVerticalTextPosition(SwingConstants.BOTTOM);
			btnEstadisticas.setHorizontalTextPosition(SwingConstants.CENTER);
			btnEstadisticas.setIcon(new ImageIcon(CompeticionX.class
					.getResource("/recursos/estadisticas-icono-7540-32.png"))); //$NON-NLS-1$
			btnEstadisticas.setFont(new Font("Tahoma", Font.PLAIN, 16)); //$NON-NLS-1$
			btnEstadisticas.setBounds(425, 464, 116, 61);
			VentanaCompeticionX.getContentPane().add(btnEstadisticas);
		}
		{
			btnEditar = new JButton(Messages.getString("CompeticionX.33")); //$NON-NLS-1$
			btnEditar.addActionListener(new editarActionListener());
			btnEditar.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
			btnEditar.setToolTipText(Messages.getString("CompeticionX.34")); //$NON-NLS-1$
			btnEditar.setFont(new Font("Tahoma", Font.PLAIN, 16)); //$NON-NLS-1$
			btnEditar.setHorizontalTextPosition(SwingConstants.CENTER);
			btnEditar.setVerticalTextPosition(SwingConstants.BOTTOM);
			btnEditar.setIcon(new ImageIcon(CompeticionX.class
					.getResource("/recursos/editar-icono-5189-32.png"))); //$NON-NLS-1$
			btnEditar.setBounds(163, 464, 97, 61);
			VentanaCompeticionX.getContentPane().add(btnEditar);
		}
		{
			btnAtras = new JButton(Messages.getString("CompeticionX.37")); //$NON-NLS-1$
			btnAtras.setMnemonic('B');
			btnAtras.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
			btnAtras.setToolTipText(Messages.getString("CompeticionX.38")); //$NON-NLS-1$
			btnAtras.addActionListener(new atrasActionListener());
			btnAtras.setFont(new Font("Tahoma", Font.PLAIN, 16)); //$NON-NLS-1$
			btnAtras.setIcon(new ImageIcon(CompeticionX.class
					.getResource("/recursos/Back.png"))); //$NON-NLS-1$
			btnAtras.setBounds(832, 484, 109, 41);
			VentanaCompeticionX.getContentPane().add(btnAtras);
		}
		{
			sPParticipantes = new JScrollPane();
			sPParticipantes.setBounds(617, 77, 334, 373);
			VentanaCompeticionX.getContentPane().add(sPParticipantes);
			{
				listParticipantes = new JList();
				listParticipantes
						.setToolTipText(Messages
								.getString("CompeticionX.listParticipantes.toolTipText")); //$NON-NLS-1$
				listParticipantes.setCursor(Cursor
						.getPredefinedCursor(Cursor.HAND_CURSOR));
				listParticipantes
						.addListSelectionListener(new ListSelectionListener() {
							public void valueChanged(ListSelectionEvent arg0) {
								InformacionParticipante ip = null;
								ip = new InformacionParticipante(
										VentanaCompeticionX);
								ip.VentanaInfoParticipante.setVisible(true);
								ip.VentanaInfoParticipante
										.setTitle(listParticipantes
												.getSelectedValue().toString());

								// CARGAR DATOS
							}
						});
				listParticipantes.setBorder(new TitledBorder(null, Messages
						.getString("CompeticionX.41"), TitledBorder.LEADING, //$NON-NLS-1$
						TitledBorder.TOP, null, null));
				listParticipantes
						.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
				DefaultListModel modeloLista = new DefaultListModel();
				listParticipantes.setModel(modeloLista);
				dominio.Util.aniadeListaPersona(modeloLista,
						dominio.Util.generaParticipantes());
				listParticipantes.setCellRenderer(new OtroListCellRenderer(0));
				sPParticipantes.setViewportView(listParticipantes);
			}
			{
				toolBar = new JToolBar();
				sPParticipantes.setColumnHeaderView(toolBar);
				{
					btnNotificar = new JButton(
							Messages.getString("CompeticionX.42")); //$NON-NLS-1$
					btnNotificar.setCursor(Cursor
							.getPredefinedCursor(Cursor.HAND_CURSOR));
					btnNotificar
							.addActionListener(new notificarActionListener());
					btnNotificar.setToolTipText(Messages
							.getString("CompeticionX.43")); //$NON-NLS-1$
					btnNotificar.setHorizontalAlignment(SwingConstants.RIGHT);
					btnNotificar.setFont(new Font("Tahoma", Font.PLAIN, 14)); //$NON-NLS-1$
					btnNotificar
							.setIcon(new ImageIcon(
									CompeticionX.class
											.getResource("/recursos/enviar-correo-icono-6932-32.png"))); //$NON-NLS-1$
					toolBar.add(btnNotificar);
				}
				{
					btnAadirParticipante = new JButton(
							Messages.getString("CompeticionX.46")); //$NON-NLS-1$
					btnAadirParticipante.setToolTipText(Messages
							.getString("CompeticionX.47")); //$NON-NLS-1$
					btnAadirParticipante.setCursor(Cursor
							.getPredefinedCursor(Cursor.HAND_CURSOR));
					btnAadirParticipante
							.addActionListener(new participanteActionListener());
					btnAadirParticipante
							.setIcon(new ImageIcon(
									CompeticionX.class
											.getResource("/recursos/panel_usuario_editar_info32.png"))); //$NON-NLS-1$
					btnAadirParticipante
							.setHorizontalAlignment(SwingConstants.RIGHT);
					btnAadirParticipante.setFont(new Font("Tahoma", Font.PLAIN, //$NON-NLS-1$
							14));
					toolBar.add(btnAadirParticipante);
				}
			}
		}
		{
			btnAyuda = new JButton(""); //$NON-NLS-1$
			btnAyuda.setMnemonic('H');
			btnAyuda.addActionListener(new AyudaActionListener());
			btnAyuda.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
			btnAyuda.setToolTipText(Messages.getString("CompeticionX.51")); //$NON-NLS-1$
			btnAyuda.setIcon(new ImageIcon(CompeticionX.class
					.getResource("/recursos/help.png"))); //$NON-NLS-1$
			btnAyuda.setBounds(933, 0, 36, 25);
			VentanaCompeticionX.getContentPane().add(btnAyuda);
		}

		{
			menuBar = new JMenuBar();
			VentanaCompeticionX.setJMenuBar(menuBar);
			{
				mnArchivo = new JMenu(Messages.getString("CompeticionX.53")); //$NON-NLS-1$
				mnArchivo.setMnemonic('1');
				mnArchivo.setCursor(Cursor
						.getPredefinedCursor(Cursor.HAND_CURSOR));
				menuBar.add(mnArchivo);
				{
					mntmBorrar = new JMenuItem(
							Messages.getString("CompeticionX.54")); //$NON-NLS-1$
					mntmBorrar.setCursor(Cursor
							.getPredefinedCursor(Cursor.HAND_CURSOR));
					mntmBorrar.addActionListener(new BorrarActionListener(
							ventanaInvocadora));
					mntmBorrar.setIcon(new ImageIcon(CompeticionX.class
							.getResource("/recursos/eliminar.png"))); //$NON-NLS-1$
					mnArchivo.add(mntmBorrar);
				}
				{
					mntmEditar = new JMenuItem(
							Messages.getString("CompeticionX.56")); //$NON-NLS-1$
					mntmEditar.setCursor(Cursor
							.getPredefinedCursor(Cursor.HAND_CURSOR));
					mntmEditar.addActionListener(new editarActionListener());
					mntmEditar
							.setIcon(new ImageIcon(
									CompeticionX.class
											.getResource("/recursos/editar-icono-5189-32.png"))); //$NON-NLS-1$
					mnArchivo.add(mntmEditar);
				}
				{
					mntmEstadisticas = new JMenuItem(
							Messages.getString("CompeticionX.58")); //$NON-NLS-1$
					mntmEstadisticas.setCursor(Cursor
							.getPredefinedCursor(Cursor.HAND_CURSOR));
					mntmEstadisticas
							.addActionListener(new estadisticasActionListener());
					{
						separator_3 = new JSeparator();
						mnArchivo.add(separator_3);
					}
					mntmEstadisticas
							.setIcon(new ImageIcon(
									CompeticionX.class
											.getResource("/recursos/estadisticas-icono-7540-32.png"))); //$NON-NLS-1$
					mnArchivo.add(mntmEstadisticas);

				}
				{
					separator = new JSeparator();
					mnArchivo.add(separator);
				}
				{
					mnCambiarIdioma = new JMenu(
							Messages.getString("CompeticionX.60")); //$NON-NLS-1$
					mnCambiarIdioma.setCursor(Cursor
							.getPredefinedCursor(Cursor.HAND_CURSOR));
					mnCambiarIdioma.setToolTipText(Messages
							.getString("CompeticionX.61")); //$NON-NLS-1$
					mnCambiarIdioma.setIcon(new ImageIcon(Menu.class
							.getResource("/recursos/select_language_32.png"))); //$NON-NLS-1$
					mnArchivo.add(mnCambiarIdioma);
					{
						mntmEspaol = new JRadioButtonMenuItem(
								Messages.getString("CompeticionX.63")); //$NON-NLS-1$
						mntmEspaol.setCursor(Cursor
								.getPredefinedCursor(Cursor.HAND_CURSOR));
						mntmEspaol.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent e) {
								Util.internacionalizarMensajes("castellano");
								Messages.setIdioma("castellano"); //$NON-NLS-1$
								CompeticionX ventana = new CompeticionX(
										ventanaInvocadora);
								ventana.VentanaCompeticionX.setVisible(true);
								VentanaCompeticionX.setVisible(false);
								ventana.mntmEspaol.setSelected(true);
								ventana.mntmIngls.setSelected(false);
								ventana.rellenaCampos(com);
							}
						});
						buttonGroup.add(mntmEspaol);
						// mntmEspaol.setSelected(true);
						mntmEspaol.setToolTipText(Messages
								.getString("CompeticionX.64")); //$NON-NLS-1$
						mntmEspaol.setIcon(new ImageIcon(Menu.class
								.getResource("/recursos/banderaEsp.gif"))); //$NON-NLS-1$
						mnCambiarIdioma.add(mntmEspaol);

					}
					{
						mntmIngls = new JRadioButtonMenuItem(
								Messages.getString("CompeticionX.2")); //$NON-NLS-1$
						mntmIngls.setCursor(Cursor
								.getPredefinedCursor(Cursor.HAND_CURSOR));
						mntmIngls.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent e) {
								Util.internacionalizarMensajes("Inglés");
								Messages.setIdioma("inglés"); //$NON-NLS-1$
								CompeticionX ventana = new CompeticionX(
										ventanaInvocadora);
								ventana.VentanaCompeticionX.setVisible(true);
								VentanaCompeticionX.setVisible(false);
								ventana.mntmEspaol.setSelected(false);
								ventana.mntmIngls.setSelected(true);
								ventana.rellenaCampos(com);

							}
						});
						buttonGroup.add(mntmIngls);
						mntmEspaol.setSelected(true);
						mntmIngls.setToolTipText("Change to English"); //$NON-NLS-1$
						mntmIngls.setIcon(new ImageIcon(Menu.class
								.getResource("/recursos/banderaIng.gif"))); //$NON-NLS-1$
						mnCambiarIdioma.add(mntmIngls);

					}
				}
				{
					separator_1 = new JSeparator();
					mnArchivo.add(separator_1);
				}
				{
					mntmAtras = new JMenuItem(
							Messages.getString("CompeticionX.69")); //$NON-NLS-1$
					mntmAtras.setCursor(Cursor
							.getPredefinedCursor(Cursor.HAND_CURSOR));
					mntmAtras.addActionListener(new atrasActionListener());

					mntmAtras.setIcon(new ImageIcon(CompeticionX.class
							.getResource("/recursos/Back.png"))); //$NON-NLS-1$
					mnArchivo.add(mntmAtras);
				}
				{
					mntmSalir = new JMenuItem(
							Messages.getString("CompeticionX.71")); //$NON-NLS-1$
					mntmSalir.setMnemonic('E');
					mntmSalir.setCursor(Cursor
							.getPredefinedCursor(Cursor.HAND_CURSOR));
					mntmSalir.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							// VentanaCompeticionX.dispose();
							if (JOptionPane.showConfirmDialog(
									VentanaCompeticionX,
									Messages.getString("CompeticionX.72"), Messages.getString("CompeticionX.73"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.YES_OPTION) { //$NON-NLS-1$ //$NON-NLS-2$
								System.exit(0);
							}
						}
					});
					mntmSalir.setToolTipText(Messages
							.getString("CompeticionX.74")); //$NON-NLS-1$
					mntmSalir.setIcon(new ImageIcon(Menu.class
							.getResource("/recursos/login_out_32.png"))); //$NON-NLS-1$
					mnArchivo.add(mntmSalir);
				}
			}
			{
				mnGestion = new JMenu(Messages.getString("CompeticionX.76")); //$NON-NLS-1$
				mnGestion.setMnemonic('2');
				mnGestion.setCursor(Cursor
						.getPredefinedCursor(Cursor.HAND_CURSOR));
				menuBar.add(mnGestion);
				{
					mnNotificacion = new JMenuItem(
							Messages.getString("CompeticionX.77")); //$NON-NLS-1$
					mnNotificacion.setCursor(Cursor
							.getPredefinedCursor(Cursor.HAND_CURSOR));
					mnNotificacion
							.addActionListener(new notificarActionListener());
					mnNotificacion
							.setIcon(new ImageIcon(
									CompeticionX.class
											.getResource("/recursos/enviar-correo-icono-6932-32.png"))); //$NON-NLS-1$
					mnGestion.add(mnNotificacion);
				}
				{
					mnAniadirParticipante = new JMenuItem(
							Messages.getString("CompeticionX.79")); //$NON-NLS-1$
					mnAniadirParticipante.setCursor(Cursor
							.getPredefinedCursor(Cursor.HAND_CURSOR));
					mnAniadirParticipante
							.addActionListener(new participanteActionListener());
					mnAniadirParticipante
							.setIcon(new ImageIcon(
									CompeticionX.class
											.getResource("/recursos/panel_usuario_editar_info32.png"))); //$NON-NLS-1$
					mnGestion.add(mnAniadirParticipante);
				}

			}
			{
				mnAyuda = new JMenu(Messages.getString("CompeticionX.81")); //$NON-NLS-1$
				mnAyuda.setMnemonic('3');
				mnAyuda.setCursor(Cursor
						.getPredefinedCursor(Cursor.HAND_CURSOR));
				menuBar.add(mnAyuda);
				{
					mntmAyuda = new JMenuItem(
							Messages.getString("CompeticionX.82")); //$NON-NLS-1$
					mntmAyuda.setCursor(Cursor
							.getPredefinedCursor(Cursor.HAND_CURSOR));
					mntmAyuda.addActionListener(new AyudaActionListener());
					mntmAyuda.setIcon(new ImageIcon(Menu.class
							.getResource("/recursos/Ayuda.png"))); //$NON-NLS-1$
					mnAyuda.add(mntmAyuda);
				}

				{
					mntmAcercaDe = new JMenuItem(
							Messages.getString("CompeticionX.85")); //$NON-NLS-1$
					mntmAcercaDe.setCursor(Cursor
							.getPredefinedCursor(Cursor.HAND_CURSOR));
					mntmAcercaDe.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							AcercaDe app = null;
							app = new AcercaDe(VentanaCompeticionX);
							app.VentanaAcercaDe.setVisible(true);
							VentanaCompeticionX.enable(false);
						}
					});
					mntmAcercaDe.setIcon(new ImageIcon(Menu.class
							.getResource("/recursos/LOGO-pqeq.png"))); //$NON-NLS-1$
					mnAyuda.add(mntmAcercaDe);
				}
			}
		}
		{
			lblImagen = new JLabel(Messages.getString("CompeticionX.87")); //$NON-NLS-1$
			lblImagen.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null,
					null));
			lblImagen.setHorizontalAlignment(SwingConstants.CENTER);
			lblImagen.setBounds(850, 8, 64, 64);
			VentanaCompeticionX.getContentPane().add(lblImagen);
		}
		Util.recuperarIdioma(mntmEspaol, mntmIngls);
	}

	String cogerIconos(Competicion c) {
		String icono = ""; //$NON-NLS-1$
		switch (c.getTipo()) {
		case "10.000m": //$NON-NLS-1$
			icono = "10000m64.png"; //$NON-NLS-1$
			break;
		case "Carrera popular": //$NON-NLS-1$
			icono = "CarreraPopular64.png"; //$NON-NLS-1$
			break;
		case "Cross": //$NON-NLS-1$
			icono = "cross64x64.png"; //$NON-NLS-1$
			break;
		case "Duatlón": //$NON-NLS-1$
			icono = "Duatlon64.png"; //$NON-NLS-1$
			break;
		case "Maratón": //$NON-NLS-1$
			icono = "Maraton64.png"; //$NON-NLS-1$
			break;
		case "Media maratón": //$NON-NLS-1$
			icono = "MediaMaraton64.png"; //$NON-NLS-1$
			break;
		case "Montaña": //$NON-NLS-1$
			icono = "Montaña64.png"; //$NON-NLS-1$
			break;
		case "San Silvestre": //$NON-NLS-1$
			icono = "SanSilvestre64.png"; //$NON-NLS-1$
			break;
		case "Triatlón": //$NON-NLS-1$
			icono = "triatlon60s.png"; //$NON-NLS-1$
			break;
		}
		return icono;
	}

	void rellenaCampos(Competicion c) {
		com=c;
		lblCompeticionx.setText(c.getNombre());
		lblDia_.setText(c.getFecha());
		lblHora_.setText(c.getHora());
		lblPremio_.setText(c.getPremios());
		lblPrecio_.setText(c.getPrecioIns());
		lblMetaM.setText(c.getMeta());
		lblSalidaM.setText(c.getSalida());
		lblDificultadM.setText(c.getDificultad());
		lblDistanciaM.setText(c.getDistancia());
		lblImagen.setText(""); //$NON-NLS-1$
		lblImagen.setIcon(new ImageIcon(Menu.class.getResource("/recursos/" //$NON-NLS-1$
				+ cogerIconos(c))));
	}

	private class AyudaActionListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			JOptionPane
					.showMessageDialog(
							VentanaCompeticionX,
							Messages.getString("CompeticionX.39"), //$NON-NLS-1$
							Messages.getString("CompeticionX.40"), JOptionPane.INFORMATION_MESSAGE); //$NON-NLS-1$

		}
	}

	private class atrasActionListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			VentanaCompeticionX.setVisible(false);
			ventanaInvocadora.setExtendedState(JFrame.NORMAL);
			ventanaInvocadora.setVisible(true);
			ventanaInvocadora.setEnabled(true);
		}
	}

	private class notificarActionListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			JOptionPane.showMessageDialog(VentanaCompeticionX,
					Messages.getString("CompeticionX.88"), //$NON-NLS-1$
					Messages.getString("CompeticionX.89"), //$NON-NLS-1$
					JOptionPane.INFORMATION_MESSAGE);
		}
	}

	private class editarActionListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			AddCompeticion v=new AddCompeticion(VentanaCompeticionX);
			v.VentanaAnadirCompeticion.setVisible(true);
			v.VentanaAnadirCompeticion.setTitle(Messages.getString("CompeticionX.99"));
			v.modificar(com);
		}
	}

	private class BorrarActionListener implements ActionListener {
		JFrame ventanaInvocadora;

		public BorrarActionListener(JFrame ventana) {
			this.ventanaInvocadora = ventana;
		}

		public void actionPerformed(ActionEvent e) {
			if (JOptionPane
					.showOptionDialog(
							VentanaCompeticionX,
							Messages.getString("CompeticionX.90"), //$NON-NLS-1$
							Messages.getString("CompeticionX.91"), JOptionPane.YES_NO_OPTION, //$NON-NLS-1$
							JOptionPane.QUESTION_MESSAGE, null, null, null) == 0) {
				JOptionPane.showMessageDialog(VentanaCompeticionX,
						Messages.getString("CompeticionX.92"), //$NON-NLS-1$
						Messages.getString("CompeticionX.93"), //$NON-NLS-1$
						JOptionPane.INFORMATION_MESSAGE);
				VentanaCompeticionX.setVisible(false);

				ventanaInvocadora.setExtendedState(JFrame.NORMAL);
				ventanaInvocadora.setVisible(true);
				ventanaInvocadora.setEnabled(true);
				
			}
		}
	}

	private class participanteActionListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			AddParticipante ap = null;

			ap = new AddParticipante(VentanaCompeticionX);

			ap.VentanaAnadirParticipante.setVisible(true);
			ap.VentanaAnadirParticipante.setTitle(Messages
					.getString("CompeticionX.94")); //$NON-NLS-1$
			VentanaCompeticionX.setVisible(false);
		}
	}

	private class estadisticasActionListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			Estadisticas es = null;
			es = new Estadisticas(lblCompeticionx.getText());
			es.VentanaEstadisticas.setVisible(true);
			
		}
	}
	public void deshabilitarEstadisticas(){
		btnEstadisticas.setEnabled(false);
		mntmEstadisticas.setEnabled(false);
	}
	public void deshabilitarParticipante(){
		btnAadirParticipante.setEnabled(false);
		mnAniadirParticipante.setEnabled(false);
	}
}

